/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.lodz.p.ftims.ProjektZespolowy2.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Łukasz Gadomski
 */
@Entity
@Table(name = "working_days")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "WorkingDay.findAll", query = "SELECT w FROM WorkingDay w"),
    @NamedQuery(name = "WorkingDay.findByWrkDayId", query = "SELECT w FROM WorkingDay w WHERE w.wrkDayId = :wrkDayId"),
    @NamedQuery(name = "WorkingDay.findByStartWork", query = "SELECT w FROM WorkingDay w WHERE w.startWork = :startWork"),
    @NamedQuery(name = "WorkingDay.findByEndWork", query = "SELECT w FROM WorkingDay w WHERE w.endWork = :endWork"),
    @NamedQuery(name = "WorkingDay.findByActive", query = "SELECT w FROM WorkingDay w WHERE w.active = :active")})
public class WorkingDay implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "wrk_day_id")
    private Integer wrkDayId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "start_work")
    @Temporal(TemporalType.TIME)
    private Date startWork;
    @Basic(optional = false)
    @NotNull
    @Column(name = "end_work")
    @Temporal(TemporalType.TIME)
    private Date endWork;
    @Basic(optional = false)
    @NotNull
    @Column(name = "active")
    private boolean active;
    @JoinColumn(name = "day_id", referencedColumnName = "day_id")
    @ManyToOne(optional = false)
    private DayOfWeek dayId;
    @JoinColumn(name = "wrk_card_id", referencedColumnName = "wrk_card_id")
    @ManyToOne(optional = false)
    private WorkingCard wrkCardId;

    public WorkingDay() {
    }

    public WorkingDay(Integer wrkDayId) {
        this.wrkDayId = wrkDayId;
    }

    public WorkingDay(Integer wrkDayId, Date startWork, Date endWork, boolean active) {
        this.wrkDayId = wrkDayId;
        this.startWork = startWork;
        this.endWork = endWork;
        this.active = active;
    }

    public Integer getWrkDayId() {
        return wrkDayId;
    }

    public void setWrkDayId(Integer wrkDayId) {
        this.wrkDayId = wrkDayId;
    }

    public Date getStartWork() {
        return startWork;
    }

    public void setStartWork(Date startWork) {
        this.startWork = startWork;
    }

    public Date getEndWork() {
        return endWork;
    }

    public void setEndWork(Date endWork) {
        this.endWork = endWork;
    }

    public boolean getActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public DayOfWeek getDayId() {
        return dayId;
    }

    public void setDayId(DayOfWeek dayId) {
        this.dayId = dayId;
    }

    public WorkingCard getWrkCardId() {
        return wrkCardId;
    }

    public void setWrkCardId(WorkingCard wrkCardId) {
        this.wrkCardId = wrkCardId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (wrkDayId != null ? wrkDayId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof WorkingDay)) {
            return false;
        }
        WorkingDay other = (WorkingDay) object;
        if ((this.wrkDayId == null && other.wrkDayId != null) || (this.wrkDayId != null && !this.wrkDayId.equals(other.wrkDayId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.lodz.p.ftims.ProjektZespolowy2.entities.WorkingDays[ wrkDayId=" + wrkDayId + " ]";
    }
    
}
